home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / LGP250S1.ZIP / src / libgplus.5 / libgplus / vms / vms-buil.com < prev    next >
Text File  |  1992-11-09  |  12KB  |  383 lines

  1. $!
  2. $! provide support for submitting this directly...
  3. $!
  4. $flnm = f$enviroment("PROCEDURE")    ! get current procedure name
  5. $set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
  6. $!
  7. $! this command procedure is used to build the LIBGXX library for VMS
  8. $! it is assumed that the sources are in a subdirectory [-.SRC], and that
  9. $! the support modules are in this directory [.VMS]
  10. $!
  11. $! this is provided as a seperate file, since there are occasions that you
  12. $! might wish to rebuild just the library, since the other support files have
  13. $! already been built.
  14. $!
  15. $! first do some consistency checking to make sure things are OK.
  16. $say:== write sys$output
  17. $filenm=f$search("[-.src]regex.cc;-1")
  18. $if filenm.eqs."" then goto start
  19. $    say "Use the VMS-INSTALL-LIBGXX.COM file to set some things up before"
  20. $    say "attempting to use this command file.  VMS_INSTALL-LIBGXX will also"
  21. $    say "automatically call this command file to perform the build once"
  22. $    say "things are set up."
  23. $    exit 2    !return error condition
  24. $start:
  25. $!
  26. $! Define a few symbols that we will use
  27. $lib:=lib/nolog
  28. $!
  29. $lib [-]libgxx/create
  30. $!
  31. $! now compile the iostream
  32. $!
  33. $ call compile iostream-objs.list [-.iostream] c "strtoul"
  34. $!
  35. $! now compile the sources
  36. $!
  37. $ call compile src-objs.list [-.src] cc "new,delete,dtoa"
  38. $!
  39. $! We have a conflict with a file by the same name in iostream.
  40. $ gcc/plus/debug [-.src]dtoa.cc/object=dtoaxx.obj
  41. $ lib [-]libgxx dtoaxx.obj
  42. $ delete/nolog dtoaxx.obj;
  43. $!
  44. $! now include the other miscelaneous modules
  45. $!
  46. $macro/nolist gxx_main_shr
  47. $!
  48. $lib gnu_cc:[000000]gcclib -
  49.    /extract=(ALLOCA,BCMP,BCOPY,BZERO,INDEX,RINDEX,L_EPRINTF, -
  50.     L_BUILTIN_NEW,L_CAPS_NEW,L_BUILTIN_DEL, -
  51.     L_LSHRDI3,L_NEGDI2,L_UDIVDI3,L_UMODDI3,L_UDIVMODDI4)/output=t.obj
  52. $lib [-]libgxx t.obj
  53. $delete/nolog t.obj;
  54. $!
  55. $macro/nolist vms-gcclib
  56. $lib [-]libgxx vms-gcclib
  57. $delete/nolog vms-gcclib.obj;
  58. $!
  59. $gcc/debug vms-curses
  60. $lib [-]libgxx vms-curses
  61. $delete/nolog vms-curses.obj;
  62. $!
  63. $write sys$output "Library has been rebuilt."
  64. $!
  65. $!****************************************************************
  66. $write sys$output "Now building sharable image library..."
  67. $!
  68. $! G++ 1.n used GSMAJOR=1
  69. $! G++ 2.0 uses GSMAJOR=2
  70. $!
  71. $! These will be overridden by the values in the file [-]Makefile.in,
  72. $! if it is possible for the following TPU procedure to find it.
  73. $GSMAJOR := 2
  74. $GSMINOR := 1
  75. $!
  76. $edit := edit
  77. $edit/tpu/nosection/nodisplay/command=sys$input
  78. ! this is the start of the main procedure
  79.    filename := GET_INFO (COMMAND_LINE, 'file_name') ;
  80.    mainbuffer := CREATE_BUFFER ("Makefile.in", "[-]Makefile.in") ;
  81.    newbuffer := CREATE_BUFFER("outfile");
  82.    position (beginning_of (mainbuffer));
  83.    range1 := search_quietly (LINE_BEGIN & "LIBG++_DIST_VERSION" & 
  84.     ((SPAN(" ") & "=") | "="), FORWARD, EXACT) ; 
  85.    if range1 <> 0 then
  86.     position (end_of (range1));
  87.     move_horizontal(1);
  88.     mark1 := MARK(NONE);
  89.     range1 := search_quietly (LINE_END, FORWARD, EXACT) ; 
  90.     position (beginning_of (range1));
  91.     mark2 := MARK(NONE);
  92.     range1 := CREATE_RANGE (mark1, mark2);
  93.     position (beginning_of(newbuffer));
  94.     copy_text (range1);
  95.     position (beginning_of(newbuffer));
  96.     LOOP
  97.       range1 := search_quietly (".", FORWARD, EXACT) ; 
  98.       exitif range1 = 0;
  99.       position (beginning_of (range1));
  100.       erase_character(1);
  101.       split_line;
  102.       ENDLOOP;
  103.     SET(OUTPUT_FILE, newbuffer, "libgxx_version.txt");
  104.         write_file (newbuffer);
  105.     endif;
  106.   quit;
  107. $!
  108. $OPEN IFILE$ LIBGXX_VERSION.TXT
  109. $READ/END=DONE IFILE$ GSMAJOR
  110. $READ/END=DONE IFILE$ GSMINOR
  111. $DONE:CLOSE IFILE$
  112. $if f$search("libgxx_version.txt").nes."" then delete/nolog libgxx_version.txt;
  113. $!
  114. $!
  115. $! Since libgxx_vector.mar is not shipped, fndvec will bump gsmajor.
  116. $gcc/debug fndvec.c/define=("GSMAJOR=''gsmajor'","GSMINOR=''gsminor'")
  117. $link fndvec.obj+GNU_CC:[000000]gcclib/lib+sys$library:vaxcrtl/lib/nomap
  118. $
  119. $! compile the transfer vectors for the sharable library
  120. $LIB/LIST=T.TMP/names [-]libgxx.OLB
  121. $name=f$environment("PROCEDURE")
  122. $fndvec=="$"+f$parse(name,,,"DEVICE")+f$parse(name,,,"DIRECTORY")+"FNDVEC"
  123. $fndvec libgxx_vector.mar t.tmp
  124. $del/nolog t.tmp;
  125. $macro/nolist libgxx_vector
  126. $delete *.obj;*/nolog/excl=(gxx_main_shr.obj,libgxx_vector.obj)
  127. $!             and clean up a little bit
  128. $delete fndvec.exe;
  129. $!
  130. $! Now generate options file that we need to link the sharable image
  131. $!
  132. $! First generate a list of writable psects.  We do this by linking, which
  133. $! will generate a link map, and then examining the map.
  134. $!
  135. $! Generate the options file without a list of writable psects.
  136. $!
  137. $call buildopt
  138. $!
  139. $! Some modules might not contain any entry points, so we force the linker
  140. $! to use them all.
  141. $!
  142. $lib [-]libgxx/extract=*/output=libgxx.obj
  143. $!
  144. $! And link it.
  145. $!
  146. $!
  147. $LINK/exe=nla0:LIBGXX.EXE/MAP=LIBGXX.MAP LIBGXX_SHR_BLD.OPT/OPTIONS
  148. $search libgxx.map ",  WRT,",",  SHR,"/match=and/output=t.wrt
  149. $osect=" "
  150. $changeflag==0
  151. $if f$search("libgxx.cmn").eqs."" then create libgxx.cmn
  152. $open ofile$ libgxx.cmn/append
  153. $OPEN IFILE$ t.wrt
  154. $loop1:
  155. $read/end=quit ifile$ line
  156. $if f$length(line).eq.0 then goto loop1
  157. $use_sect:
  158. $ijk=f$locate(" ",line)
  159. $sectnam=f$extract(0,ijk,line)
  160. $! the same psect might have appeared on several pages, on the 2nd and
  161. $! following pages the psect name and attributes appear again.
  162. $if osect.eqs.sectnam then goto loop1
  163. $osect=sectnam
  164. $write ofile$ sectnam
  165. $changeflag==1
  166. $GOTO LOOP1
  167. $quit:
  168. $close ifile$
  169. $close ofile$
  170. $del libgxx.map;/nolog
  171. $del t.wrt;/nolog
  172. $WRITE SYS$OUTPUT "List of writable psects written to libgxx.cmn"
  173. $!
  174. $! Now build the actual options file we need to finish the job...
  175. $!
  176. $call buildopt
  177. $!
  178. $    say:=write sys$output
  179. $    say "Linking sharable image library..."
  180. $
  181. $         LINK/NOMAP/SHAREABLE=[-]LIBGXX_SHR.EXE -
  182.             LIBGXX_SHR_BLD.OPT/OPTIONS
  183. $!
  184. $! Now clean up what we do not need.
  185. $!
  186. $purge/nolog *.opt
  187. $delete/nolog libgxx_vector.obj;
  188. $delete/nolog gxx_main_shr.obj;
  189. $delete/nolog libgxx.obj;
  190. $!
  191. $! now we are done building the library - now figure out if we have libgxx
  192. $!already installed.
  193. $installed = 0
  194. $if f$search("gnu_cc:[000000]libgxx_shr.exe").eqs."" then goto cpy
  195. $if f$file_attributes("gnu_cc:[000000]libgxx_shr.exe","KNOWN").eqs."TRUE" -
  196.     then installed = 1
  197. $cpy:
  198. $! copy libgxx_shr.olb gnu_cc:[000000]
  199. $on error then goto noclean
  200. $ copy [-]libgxx_shr.exe gnu_cc:[000000]
  201. $ lnm=f$trnlnm("GNU_CC")-".]"+"]libgxx_shr"
  202. $ assign/system 'lnm' libgxx_shr
  203. $ delete/nolog [-]libgxx_shr.exe;
  204. $type/nopage sys$input
  205. Finished building library.  LIBGXX_SHR.EXE has been copied to gnu_cc:[000000].
  206. $if  installed.eq.0 then goto done_build
  207. $if f$privilege("CMKRNL").eqs."FALSE" then goto noinst
  208. $install:==$install
  209. $if installed.eq.1 then install replace gnu_cc:[000000]libgxx_shr.exe
  210. $type/nopage sys$input
  211. A previous version was installed before, it has been replaced by the new one.
  212. $ goto done_build
  213. $noinst:
  214. $type/nopage sys$input
  215. A previous version of libg++ was installed before, but this account does not
  216. have CMKRNL, so the image has not been replaced.
  217. $goto done_build
  218. $not_inst:
  219. $type/nopage sys$input
  220. You have the option of installing the executable to make it a known image.
  221. $
  222. $!
  223. $noclean:
  224. $type/nopage sys$input
  225. Finished building library.  LIBGXX_SHR.EXE has NOT been copied to gnu_cc:[000000]
  226. since you ignored the instructions about having write access to gnu_cc:[000000].
  227. Not to worry, however, the file has been left in the parent directory of the
  228. vms subdirectory, and you can copy the file by hand. Once you have done this,
  229. you have the option of installing the executable to make it a known image.  
  230. $exit
  231. $done_build:
  232. $on error then exit
  233. $!
  234. $! and clean up a little bit.
  235. $!
  236. $!
  237. $ if f$search("sys$library:libgxx_shr.olb").nes."" then -
  238.     delete/nolog sys$library:libgxx_shr.olb;
  239. $exit
  240. $!
  241. $!
  242. $! Subroutine to generate a linker options file.  It requires as input the
  243. $! file libgxx.cmn, listing the writable psects in the image, and it needs
  244. $! to take a peek at libgxx_vector.mar to find out the gsnumbers.
  245. $! The output is in the files libgxx_shr_bld.opt and options_shr.opt.
  246. $!
  247. $! When building the library we need the LCL modifier, to tell the linker
  248. $! that the psect is local.  When linking to the library we must not use it.
  249. $buildopt:
  250. $subroutine
  251. $gsmajor = 1
  252. $gsminor = 1
  253. $open ofile$ libgxx_shr_bld.opt/WRITE
  254. $open  user_link_opt$ options_shr.opt/WRITE
  255. $write user_link_opt$ "LIBGXX_SHR/SHARE"
  256. $write user_link_opt$ "SYS$SHARE:VAXCRTL/SHARE"
  257. $write user_link_opt$ "gnu_cc:[000000]gcclib/lib
  258. $write user_link_opt$ "psect_attr=curscr,noshr"
  259. $write user_link_opt$ "psect_attr=stdscr,noshr"
  260. $write user_link_opt$ "psect_attr=stdin,noshr"
  261. $write user_link_opt$ "psect_attr=stdout,noshr"
  262. $write user_link_opt$ "psect_attr=stderr,noshr"
  263. $write user_link_opt$ "psect_attr=_ctype_,noshr"
  264. $write ofile$ "!"
  265. $write ofile$ "NAME = libgxx_SHR"
  266. $!
  267. $! first find the gsmatch parameters from the ident field of libgxx_vector.mar
  268. $open ifile$ libgxx_vector.mar
  269. $gsloop:
  270. $read/end=nogs ifile$ line
  271. $ijk=f$locate(".IDENT",line)
  272. $if ijk.eq.f$length(line) then goto gsloop
  273. $ijk=f$locate("/",line)+1
  274. $line=f$extract(ijk,f$length(line)-ijk-1,line)
  275. $ijk=f$locate("-",line)
  276. $gsmajor='f$extract(0,ijk,line)
  277. $gsminor='f$extract(ijk+1,f$length(line)-ijk-1,line)
  278. $close ifile$
  279. $nogs:
  280. $write ofile$ "IDENTIFICATION = """,gsmajor,".",gsminor,"""
  281. $write ofile$ "!
  282. $write ofile$ "!
  283. $write ofile$ "! Increase the second number by one for each new routine added
  284. $!write ofile$ "GSMATCH = LEQUAL,",gsmajor,",",gsminor
  285. $write ofile$ "GSMATCH = EQUAL,",gsmajor,",",gsminor
  286. $write ofile$ "!
  287. $write ofile$ "PSECT_ATTR = $PDATA,PIC,EXE
  288. $write ofile$ "PSECT_ATTR = $MACRO,PIC,EXE
  289. $write ofile$ "PSECT_ATTR = $TOKEN,PIC,EXE
  290. $write ofile$ "!
  291. $write ofile$ "! If new routines add any more writable psects, give them PSECT_ATTR's of LCL
  292. $write ofile$ "! and NOSHR
  293. $if f$search("libgxx.cmn").eqs."" then goto nofile1
  294. $open ifile$ libgxx.cmn
  295. $loop:read ifile$ line/end=done
  296. $write ofile$ "PSECT_ATTR = ''line',LCL,NOSHR"
  297. $write user_link_opt$ "PSECT_ATTR = ''line',NOSHR"
  298. $goto loop
  299. $done:close ifile$
  300. $!
  301. $! Now add the universal symbols
  302. $!
  303. $if f$search("libgxx_vector.mar").eqs."" then goto nouniversal
  304. $search libgxx_vector.mar "UNIVERSAL"/OUTPUT=universal.lst
  305. $open ufile$ universal.lst
  306. $uloop:
  307. $read/end=udone ufile$ line
  308. $write ofile$ f$extract(1,255,line)
  309. $goto uloop
  310. $udone:close ufile$
  311. $delete/nolog universal.lst;
  312. $!
  313. $nouniversal:
  314. $write ofile$ "!"
  315. $write ofile$ "! New writable psect names should be added to CLUSTER3"
  316. $write ofile$ "COLLECT = CLUSTER1,$$$$libgxx_VECTOR"
  317. $open ifile$ libgxx.cmn
  318. $loop1:read ifile$ line/end=done1
  319. $write ofile$ "COLLECT = CLUSTER1,"+LINE
  320. $GOTO LOOP1
  321. $DONE1:CLOSE IFILE$
  322. $nofile1:
  323. $write ofile$ "COLLECT = CLUSTER2,$LOCAL,$BLANK"
  324. $write ofile$ "COLLECT = CLUSTER2,$CODE,$PDATA"
  325. $write ofile$ "!"
  326. $write ofile$ "gxx_main_shr"
  327. $write ofile$ "libgxx_VECTOR.OBJ"
  328. $write ofile$ "libgxx.OBJ"
  329. $write ofile$ "SYS$LIBRARY:VAXCRTL/SHARE"
  330. $write ofile$ "psect_attr=curscr,noshr"
  331. $write ofile$ "psect_attr=stdscr,noshr"
  332. $write ofile$ "psect_attr=stdin,noshr"
  333. $write ofile$ "psect_attr=stdout,noshr"
  334. $write ofile$ "psect_attr=stderr,noshr"
  335. $write ofile$ "psect_attr=_ctype_,noshr"
  336. $close user_link_opt$
  337. $close ofile$
  338. $exit
  339. $endsubroutine
  340. $!
  341. $!
  342. $!  This routine takes parameter p1 to be a linker options file with a list
  343. $!  of object files that are needed.  It extracts the names, and compiles
  344. $!  each source module, one by one.
  345. $!
  346. $!  Parameter P2 is a list of files which will appear in the options file
  347. $!  that should not be compiled.  This allows us to handle special cases.
  348. $!
  349. $compile:
  350. $subroutine
  351. $on error then goto c_err
  352. $on control_y then goto c_err
  353. $open ifile$ 'p1'
  354. $loop: read ifile$ line/end=c_done
  355. $!
  356. $i=0
  357. $loop1:
  358. $flnm=f$element(i,",",line)
  359. $i=i+1
  360. $if flnm.eqs."" then goto loop
  361. $if flnm.eqs."," then goto loop
  362. $if f$locate(flnm,"''p4'").nes.f$length("''p4'") then goto loop1
  363. $!
  364. $name = f$edit("''p2'''flnm'.''p3'","collapse")
  365. $set verify
  366. $ gcc/plus/debug 'name'
  367. $ lib [-]libgxx 'flnm'.obj
  368. $ delete/nolog 'flnm'.obj;
  369. $!'f$verify(0)
  370. $goto loop1
  371. $!
  372. $goto loop
  373. $!
  374. $! In case of error or abort, go here (In order to close file).
  375. $!
  376. $c_err: !'f$verify(0)
  377. $close ifile$
  378. $exit %x2c
  379. $!
  380. $c_done:
  381. $close ifile$
  382. $endsubroutine
  383.